package com.mavenq.fly.business.controller;

import com.alibaba.fastjson.JSONObject;
import com.mavenq.fly.commons.resp.ResponseObj;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


@RestController
@RequestMapping(value = "/remote")
@Slf4j
public class RemoteCallController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping(value = "/call/person")
    public Object getRemoteRet() throws Exception{
        ResponseEntity<ResponseObj> forEntity = restTemplate.getForEntity("http://192.168.1.101:8081/person/list/2", ResponseObj.class);
        log.info("获取远程结果：{}", JSONObject.toJSONString(forEntity));
        return forEntity;
    }
}
